package com.ckm.provider;

import com.ckm.creator.DefaultMongoSourceCreator;
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
import org.springframework.data.mongodb.MongoDatabaseFactory;

import java.util.Map;


public abstract class DBMongoSourceProvider extends AbstractMongoSourceProvider{

    private final String uri;
    private final String collectionName;

    public DBMongoSourceProvider(DefaultMongoSourceCreator defaultMongoSourceCreator, String uri, String collectionName) {
        super(defaultMongoSourceCreator);
        this.uri = uri;
        this.collectionName = collectionName;
    }


    @Override
    public Map<String, MongoDatabaseFactory> loadMongoSource() {
        return createMongoSourceMap(getMongoSource(uri,collectionName));
    }

    protected abstract Map<String, MongoProperties> getMongoSource(String uri, String collectionName);
}
